import Mock from "mockjs";
export default {
  getMenu: (config) => {
    const { username, password } = JSON.parse(config.body);
    // 先判断用户是否存在
    // 判断账号和密码是否对应
    if (username === "lqd" && password === "123456") {
      return {
        code: 200,
        data: {
          menu: [
            {
              path: "/home",
              name: "home",
              label: "首页",
              icon: "HomeFilled",
              url: "home/Home",
            },
            {
              path: "/plccontent",
              name: "plccontent",
              label: "PLC连接",
              icon: "Promotion",
              url: "plc/PlcContent",
            },
            {
              path: "/user",
              name: "user",
              label: "用户管理",
              icon: "User",
              url: "user/User",
            },
            {
              label: "其他",
              icon: "location",
              path: "/other",
              children: [
                {
                  path: "/page1",
                  name: "page1",
                  label: "页面1",
                  icon: "setting",
                  url: "Page1",
                },
                {
                  path: "/page2",
                  name: "page2",
                  label: "页面2",
                  icon: "setting",
                  url: "Page2",
                },
                {
                  path: "/page3",
                  name: "page3",
                  label: "页面3",
                  icon: "setting",
                  url: "Page3",
                },
                {
                  path: "/page4",
                  name: "page4",
                  label: "页面4",
                  icon: "setting",
                  url: "Page4",
                  meta: {
                    keepAlive: true,
                  },
                },
              ],
            },
          ],
          token: Mock.Random.guid(),
          message: "获取成功",
        },
      };
    } else if (username === "cp" && password === "123456") {
      return {
        code: 200,
        data: {
          menu: [
            {
              path: "/home",
              name: "home",
              label: "首页",
              icon: "HomeFilled",
              url: "home/Home",
            },
            {
              path: "/plccontent",
              name: "plccontent",
              label: "PLC连接",
              icon: "Promotion",
              url: "plc/PlcContent",
            },
            {
              label: "其他",
              icon: "location",
              path: "/other",
              children: [
                {
                  path: "/page1",
                  name: "page1",
                  label: "页面1",
                  icon: "setting",
                  url: "Page1",
                },
                {
                  path: "/page2",
                  name: "page2",
                  label: "页面2",
                  icon: "setting",
                  url: "Page2",
                },
                {
                  path: "/page3",
                  name: "page3",
                  label: "页面3",
                  icon: "setting",
                  url: "Page3",
                },
                {
                  path: "/page4",
                  name: "page4",
                  label: "页面4",
                  icon: "setting",
                  url: "Page4",
                  meta: {
                    keepAlive: true,
                  },
                },
              ],
            },
          ],
          token: Mock.Random.guid(),
          message: "获取成功",
        },
      };
    } else {
      return {
        code: 501,
        data: {
          message: "密码错误",
        },
      };
    }
  },
};
